//
//  UITableView+ZKChain.m
//  ChainFun
//
//  Created by 洪绵卫 on 2022/1/10.
//

#import "UITableView+ZKChain.h"

@implementation UITableView (ZKChain)

+ (UITableView * _Nonnull (^)(void))zk_allocInit{
    return ^{
         UITableView *v = [[UITableView alloc]init];
        return v;
    };
}

+ (UITableView * _Nonnull (^)(CGRect))zk_allocInitWithFrame{
    return ^(CGRect rect){
        UITableView * v = [[UITableView alloc]initWithFrame:rect];
        return v;
    };
}

- (UITableView * _Nonnull (^)(CGRect))zk_frame{
    return ^(CGRect rect){
        self.frame = rect;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIColor * _Nonnull))zk_backgroundColor{
    return ^(UIColor *color){
        self.backgroundColor = color;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIView * _Nonnull))zk_addToSuperView{
    return ^(UIView *view){
        [view addSubview:self];
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_userInteractionEnabled{
    return ^(BOOL isUserInteractionEnabled){
        self.userInteractionEnabled = isUserInteractionEnabled;
        return self;
    };
}

- (UITableView * _Nonnull (^)(NSInteger))zk_tag{
    return ^(NSInteger tag){
        self.tag = tag;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGRect))zk_bounds;{
    return ^(CGRect rect){
        self.bounds = rect;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGPoint))zk_center{
    return ^(CGPoint point){
        self.center = point;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_alpha{
    return ^(CGFloat value){
        self.alpha = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_hidden{
    return ^(BOOL isHidden){
        self.hidden = isHidden;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIColor * _Nonnull))zk_tintColor{
    return ^(UIColor *col){
        self.tintColor = col;
        return self;
    };
}

#pragma mark UIScrollView 的
- (UITableView * _Nonnull (^)(CGPoint))zk_contentOffset{
    return ^(CGPoint offset){
        self.contentOffset = offset;
        return self;
    };
}

/// 内容大小
- (UITableView * _Nonnull (^)(CGSize))zk_contentSize{
    return ^(CGSize size){
        self.contentSize = size;
        return self;
    };
}

/// 内容边距
- (UITableView * _Nonnull (^)(UIEdgeInsets))zk_contentInset{
    return ^(UIEdgeInsets contentInset){
        self.contentInset = contentInset;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIScrollViewContentInsetAdjustmentBehavior))zk_contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0)){
    return ^(UIScrollViewContentInsetAdjustmentBehavior inset){
        self.contentInsetAdjustmentBehavior = inset;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_automaticallyAdjustsScrollIndicatorInsets API_AVAILABLE(ios(13.0)){
    return ^(BOOL isIndicatorInsets){
        self.automaticallyAdjustsScrollIndicatorInsets = isIndicatorInsets;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_bounces{
    return ^(BOOL value){
        self.bounces = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_alwaysBounceVertical{
    return ^(BOOL value){
        self.alwaysBounceVertical = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_alwaysBounceHorizontal{
    return ^(BOOL value){
        self.alwaysBounceHorizontal = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_pagingEnabled{
    return ^(BOOL value){
        self.pagingEnabled = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_scrollEnabled{
    return ^(BOOL value){
        self.scrollEnabled = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_showsVerticalScrollIndicator{
    return ^(BOOL value){
        self.showsVerticalScrollIndicator = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_showsHorizontalScrollIndicator{
    return ^(BOOL value){
        self.showsHorizontalScrollIndicator = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIScrollViewIndicatorStyle))zk_indicatorStyle{
    return ^(UIScrollViewIndicatorStyle style){
        self.indicatorStyle = style;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIEdgeInsets))zk_verticalScrollIndicatorInsets API_AVAILABLE(ios(11.1), tvos(11.1)){
    return ^(UIEdgeInsets value){
        self.verticalScrollIndicatorInsets = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIEdgeInsets))zk_horizontalScrollIndicatorInsets API_AVAILABLE(ios(11.1), tvos(11.1)){
    return ^(UIEdgeInsets value){
        self.horizontalScrollIndicatorInsets = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIEdgeInsets))zk_scrollIndicatorInsets{
    return ^(UIEdgeInsets value){
        self.scrollIndicatorInsets = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_minimumZoomScale{
    return ^(CGFloat value){
        self.minimumZoomScale = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_maximumZoomScale{
    return ^(CGFloat value){
        self.maximumZoomScale = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_zoomScale{
    return ^(CGFloat value){
        self.zoomScale = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_bouncesZoom{
    return ^(BOOL value){
        self.bouncesZoom = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(BOOL))zk_scrollsToTop{
    return ^(BOOL value){
        self.scrollsToTop = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIScrollViewKeyboardDismissMode))zk_keyboardDismissMode{
    return ^(UIScrollViewKeyboardDismissMode mode){
        self.keyboardDismissMode = mode;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIRefreshControl * _Nullable))zk_refreshControl API_AVAILABLE(ios(10.0)){
    return ^(UIRefreshControl *refreshControl){
        self.refreshControl = refreshControl;
        return self;
    };
}

#pragma mark UITableView 的
+ (UITableView * _Nonnull (^)(CGRect,UITableViewStyle))zk_allocInitWithFrameAndStyle{
    return ^(CGRect rect,UITableViewStyle style){
        UITableView * tab = [[UITableView alloc]initWithFrame:rect style:style];
        return tab;
    };
}

/// 设置数据源
- (UITableView * _Nonnull (^)(id <UITableViewDataSource> _Nullable))zk_dataSource{
    return ^(id <UITableViewDataSource> _Nullable dataSource){
        self.dataSource = dataSource;
        return self;
    };
}

/// 设置代理
- (UITableView * _Nonnull (^)(id <UITableViewDelegate> _Nullable))zk_delegate{
    return ^(id <UITableViewDelegate> _Nullable delegate){
        self.delegate = delegate;
        return self;
    };
}

- (UITableView * _Nonnull (^)(id <UITableViewDataSourcePrefetching> _Nullable))zk_prefetchDataSource API_AVAILABLE(ios(10.0));{
    return ^(id <UITableViewDataSourcePrefetching> _Nullable dataSource){
        self.prefetchDataSource = dataSource;
        return self;
    };
}

- (UITableView * _Nonnull (^)(id <UITableViewDragDelegate> _Nullable))zk_dragDelegate API_AVAILABLE(ios(11.0)){
    return ^(id <UITableViewDragDelegate> _Nullable dragDelegate){
        self.dragDelegate = dragDelegate;
        return self;
    };
}
   
- (UITableView * _Nonnull (^)(id <UITableViewDropDelegate> _Nullable))zk_dropDelegate API_AVAILABLE(ios(11.0)){
    return ^(id <UITableViewDropDelegate> _Nullable dropDelegate){
        self.dropDelegate = dropDelegate;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_rowHeight{
    return ^(CGFloat value){
        self.rowHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_sectionHeaderHeight{
    return ^(CGFloat value){
        self.sectionHeaderHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_sectionFooterHeight{
    return ^(CGFloat value){
        self.sectionFooterHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_estimatedRowHeight{
    return ^(CGFloat value){
        self.estimatedRowHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_estimatedSectionHeaderHeight{
    return ^(CGFloat value){
        self.estimatedSectionHeaderHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_estimatedSectionFooterHeight{
    return ^(CGFloat value){
        self.estimatedSectionFooterHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_fillerRowHeight API_AVAILABLE(ios(15.0), tvos(15.0), watchos(8.0)){
    return ^(CGFloat value){
        self.fillerRowHeight = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(CGFloat))zk_sectionHeaderTopPadding API_AVAILABLE(ios(15.0), tvos(15.0), watchos(8.0)){
    return ^(CGFloat value){
        self.sectionHeaderTopPadding = value;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIEdgeInsets))zk_separatorInset{
    return ^(UIEdgeInsets offset){
        self.separatorInset = offset;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UITableViewSeparatorInsetReference))zk_separatorInsetReference API_AVAILABLE(ios(11.0), tvos(11.0)){
    return ^(UITableViewSeparatorInsetReference reference){
        self.separatorInsetReference = reference;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIView * _Nullable))zk_backgroundView{
    return ^(UIView * _Nullable bgView){
        self.backgroundView = bgView;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UITableViewCellSeparatorStyle))zk_separatorStyle{
    return ^(UITableViewCellSeparatorStyle style){
        self.separatorStyle = style;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIColor * _Nullable))zk_separatorColor{
    return ^(UIColor *col){
        self.separatorColor = col;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIVisualEffect * _Nullable))zk_separatorEffect{
    return ^(UIVisualEffect *effect){
        self.separatorEffect = effect;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIView * _Nullable))zk_tableHeaderView{
    return ^(UIView * _Nullable view){
        self.tableHeaderView = view;
        return self;
    };
}

- (UITableView * _Nonnull (^)(UIView * _Nullable))zk_tableFooterView{
    return ^(UIView * _Nullable view){
        self.tableFooterView = view;
        return self;
    };
}

@end
